<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/pub/include.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人信息管理--<c:choose><c:when test="${empty clazzEntity}">添加信息</c:when><c:otherwise>编辑信息</c:otherwise></c:choose></title>
<link href="<%=request.getContextPath() %>/css/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.form.js"></script>
    <script type="text/javascript">
        function firm() {
            //利用对话框返回的值 （true 或者 false）
            if (confirm("提交后将无法在更改基础信息，马上提交吗？")) {
                check();
            }
        }
        function check(){
            var url = getRootPath()+"/user/adduser?m=doadd";
            var   username = $("#username").val();
            var   password = $("#password").val();
            var   phone = $("#phone").val();
            var   department = $("#department").val();
            var   position = $("#position").val();
            var   execute = $("#execute").val();
            var   depart = $("#depart").val();
            var   email = $("#email").val();
            var   permission = $("#permission").val();
            var   id = $("#id").val();
            if(username==""){
                alert("姓名不能为空");
                return false;
            }
            if(password==""){
                alert("密码不能为空");
                return false;
            }
            if(permission==0){
                alert("权限不能为空");
                return false;
            }
            <c:if test="${not empty userEntity}">
            url = getRootPath()+"/user/adduser?m=doedit";
            </c:if>
            $('#permission').attr('disabled', false);
//            alert(6234);
            var para ={
                'id' :id,
                'username':username,
                'password':password,
                'phone' :phone,
                'department':department,
                'position':position,
                'email' :email,
                'execute':execute,
                'depart' :depart,
                'permission':permission
            }
//            alert(url);
            $.ajax({
                cache:false,
                type:"POST",
                url: url,
                dataType:"json",
                data:para,
                error:function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                },
                success:function(returndata){
                    alert(returndata.data.message);
                    if(returndata.data.suc){
                        window.location.href= getRootPath()+"/user/manage?m=list";
                    }else{

                    }
                }
            });
        }
</script>
</head>
<body>
<div class="content">
<jsp:include page="../pub/top.jsp"></jsp:include>
<!--头部结束-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="left" valign="top">
<jsp:include page="../pub/left_user.jsp"></jsp:include>
</td>
<td valign="top">
	<div class="right">
	<form id="addUserFrom" action="<c:url value="/user/adduser?m=doadd"/>" method="post" onsubmit="return check(this);" style="margin:0">
	<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#d1d5d8">
	<tr>
	<td height="28" colspan="2" bgcolor="#c6dbf8" class="biaoti" style="padding:0;">
	<c:choose>
		<c:when test="${empty userEntity}">添加用户</c:when>
		<c:otherwise>编辑用户</c:otherwise>
	</c:choose>
	</td>
	</tr>

	<tr>
	<td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>姓名：</td>
        <td height="28" bgcolor="#FFFFFF">
            <input type="text" name="username" id="username" value="<c:out value="${userEntity.username}"/>" /></td>
	</tr>
	<tr>
	<td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>密码：</td>
	<td height="28" bgcolor="#FFFFFF"><input type="text" name="password" id="password" value="<c:out value="${userEntity.password}" />" /></td>
	</tr>
	<tr>
	<td width="15%" height="28" align="right" bgcolor="#edf1f7">部门：</td>
        <td height="28" bgcolor="#FFFFFF"><input type="text" name="department" id="department" value="<c:out value="${userEntity.department}" />" /></td>
    </tr>
        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>执行部门：</td>
            <td height="28" bgcolor="#FFFFFF">
                <select class="sheng" name="depart" id="depart" >
                    <option value="0">请选择执行</option>
                    <c:forEach items="${departList}" var="depart">
                        <option value="${depart.code}" ${userEntity.depart.code==depart.code?'selected=selected':''}><c:out value="${depart.value}"/></option>
                    </c:forEach>
                </select>

            </td>
        </tr>

        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7">职位：</td>
            <td height="28" bgcolor="#FFFFFF"><input type="text" name="position" id="position" value="<c:out value="${userEntity.position}" />" /></td>
        </tr>
        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>执行级别：</td>
            <td height="28" bgcolor="#FFFFFF">
                <select class="sheng" name="execute" id="execute" >
                    <option value="0">请选择级别</option>
                    <c:forEach items="${executeList}" var="execute">
                        <option value="${execute.code}" ${userEntity.execute.code==execute.code?'selected=selected':''}><c:out value="${execute.value}"/></option>
                    </c:forEach>
                </select>

            </td>
        </tr>
        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7">手机号：</td>
            <td height="28" bgcolor="#FFFFFF"><input type="text" name="phone" id="phone" value="<c:out value="${userEntity.phone}" />" /></td>
        </tr>
        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7">邮箱：</td>
            <td height="28" bgcolor="#FFFFFF"><input type="text" name="email" id="email" value="<c:out value="${userEntity.email}"/>" /></td>
        </tr>
	<tr>
        <tr>
            <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>操作权限：</td>
            <td height="28" bgcolor="#FFFFFF">
                <select class="sheng" name="permission" id="permission" >
                    <option value="0">请选择权限</option>
                    <c:forEach items="${fsTypeList}" var="permission">
                        <option value="${permission.code}" ${userEntity.permission.code==permission.code?'selected=selected':''}><c:out value="${permission.value}"/></option>
                    </c:forEach>
                </select>

            </td>
        </tr>


	</table>
	<div class="anniu">
	<p><input type="button" value="提交" class="fabu" onclick="check()"/>
		<c:choose>
			<c:when test="${empty userEntity}"><input type="reset" value="重置" class="fabu" /></c:when>
			<c:otherwise><input type="button" value="返回" class="fabu" onclick="history.back()" /></c:otherwise>
		</c:choose>
	</p>
	<input type="hidden" name="id" id="id" value="${userEntity.id}"/>
	</div>
	</form>
	</div>
	<br />
	<br />
</td>
</tr>
</table>
    <script type="text/javascript">
        $(function(){
            var userpermission = ${sessionScope.user.permission.code};
            if( userpermission != 1 )
            {
                $('#department').attr('disabled', true);
                $('#position').attr('disabled', true);
                $('#permission').attr('disabled', true);
            }
        });
    </script>
<jsp:include page="../pub/foot.jsp"></jsp:include>
</div>
</body>
</html>
